﻿#ifndef QFORMFUNCTION_H
#define QFORMFUNCTION_H

#include <QWidget>
#include"qdialogmessage.h"
#include "qcarstatusform.h"
#include "canthread.h"
#include "qbridge.h"


namespace Ui {
class QFormFunction;
}

class QFormFunction : public QWidget
{
    Q_OBJECT
private:

public:
    //  自定义单元格Type的类型，在创建单元格的Item时使用
    enum CellType{ctDirection=1000,ctTime,ctPeriod,ctID,
                  ctBitFormat,cttype,ctlength,ctdata};//各单元格的类型
    //   各字段在表格中的列号
    enum FieldColNum{colDirection=0, colTime,colPeriod,colID,
                     colBitFormat,coltype,collength,coldata};

    void createItemsARow(int noNum, QString Direction,QString Time,QString Period,QString id,
                         QString BitFormat,QString type,QString length,
                         QString data); //为某一行创建items
    void setHeader();
    void getMessage(int portNum,QString portName,int bps);
public:
    explicit QFormFunction(QWidget *parent = nullptr);
    ~QFormFunction();

private slots:
    //自定义函数
    void onThreadCar_Message(QString ID,QString TimeStamp,QString TimeFlag,
                             QString SendType,QString RemoteFlag,QString ExternFlag,
                             QString DataLen,QString Data);

    void onTreadCar_CAN_Array(uint ID,uchar * Array);

    void on_btn_Aut_send_clicked();

    void on_btn_send_clicked();

    void on_btn_stop_clicked();

    void on_act_clear_triggered();

    void on_tableinfo_customContextMenuRequested(const QPoint &pos);

    void on_act_save_triggered();

    void on_act_message_triggered();

    void on_act_car_state_triggered();
    void on_btn_sendCan_clicked();

public:
    QCarStatusForm * pCarStatus;

private:
    Ui::QFormFunction *ui;
    int m_portNum;
    QString m_portName;
    int m_bps;
//  Thread threadCar;
    QBridge *bridge;

};

#endif // QFORMFUNCTION_H
